import request from '@/utils/request'
import { tokenName } from '@/config'

export async function login(data) {
  return request({
    url: '/userLogin',
    method: 'post',
    data,
  })
}

export async function socialLogin(data) {
  return request({
    url: '/socialLogin',
    method: 'post',
    data,
  })
}

export function getUserInfo(accessToken) {
  //此处为了兼容mock.js使用data传递accessToken，如果使用mock可以走headers
  return request({
    url: '/userInfo',
    method: 'get',
    // data: {
    //   [tokenName]: accessToken,
    // },
  })
}

export function logout() {
  return request({
    url: '/logout',
    method: 'post',
  })
}

/**
 * 
 * @param {用户注册} data 
 * @returns 
 */
export async function register(data) {
  return request({
    url: '/userRegister',
    method: 'post',
    data:data
  })
}

/**
 * 用户信息修改
 * @param {y} data 
 * @returns 
 */
export async function userModify(data) {
  return request({
    url: '/userModifyInfo',
    method: 'post',
    data:data
  })
}

/**
 * 用户list
 * {
  "pageNum": 0,
  "pageSize": 0,
  "type": "",
  "userName": ""
}
 * @param {} data 
 * @returns 
 */
export async function userList(data) {
  return request({
    url: '/userListInfo',
    method: 'put',
    data:data
  })
}
